<template>
  <div>
    <!--1视图-->
    <span v-for="l in list" class="myclass">
      {{l.date}}--{{l.name}}--{{l.address}}<br>
    </span>
    <button @click="tc">弹出奇数行</button>
  </div>

</template>

<script>
export default {
  name: "ListView",
  data() {
    return {
      //2属性定义
      list:[]
    }
  }, methods: {
    //3自定义方法
    tc(){
      this.list.forEach((row,index)=>{
        if(index%2==0){
          console.log(row)
        }
      })
    },
    getList(){
      this.axios.get("list.json").then(res=>{
          this.list=res.data;
      })
    }
  }, created() {
    //4.钩子函数
    this.getList();
  }
}
</script>

<style scoped>
.myclass:hover{
  background-color: green;
}
</style>